# Strike lighting when an intel is captured

from commands import rights

def apply_script(protocol, connection, config):
    class IntelCapLightingConnection(connection):
        def on_flag_capture(self):
            Is_Admin = self.admin
            old_rights = set(tuple(s for s in self.rights))

            self.admin = True
            self.rights.update(set(rights.get('admin', ())))

            command(self, "lighting")

            self.admin=Is_Admin
            self.rights = old_rights

            connection.on_flag_capture(self)

    class IntelCapLightingProtocol(protocol):
        def on_game_end(self):
            protocol.on_game_end(self)

    return IntelCapLightingProtocol, IntelCapLightingConnection
